package com.cms.stu.service.impl;

import com.cms.stu.entity.DepEntity;
import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Service;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.cms.common.utils.PageUtils;
import com.cms.common.utils.Query;

import com.cms.stu.dao.MajorDao;
import com.cms.stu.entity.MajorEntity;
import com.cms.stu.service.MajorService;


@Service("majorService")
public class MajorServiceImpl extends ServiceImpl<MajorDao, MajorEntity> implements MajorService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        String key = (String) params.get("key");
        QueryWrapper<MajorEntity> wrapper = new QueryWrapper<>();
        if(!StringUtils.isEmpty(key)){
            wrapper.like("name", key).or().eq("id", key).or().eq("dep_id", key);
        }
        System.out.println(wrapper.toString());
        IPage<MajorEntity> page = this.page(
                new Query<MajorEntity>().getPage(params),
                wrapper
        );

        return new PageUtils(page);
    }

}